package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.service.minioservice.OSSService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件功能处理器
 */
@Slf4j
@RequestMapping("/admin/product")
@RestController
public class FileController {

    @Autowired
    private OSSService ossService;
    /**
     * 文件上传
     */
    @PostMapping("/fileUpload")
    public Result uploadFile(MultipartFile file) throws Exception {
//        String filename = file.getOriginalFilename();
//        String name = file.getName();
//        long size = file.getSize();
//        String contentType = file.getContentType();
//        log.info("文件名:,文件大小:,文件类型:",filename,contentType,size,name);

        String url=ossService.uploadFile(file);
        return Result.ok(url);
    }


}
